package com.x.base.core.project.server;

import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;

import com.x.base.core.gson.GsonPropertyObject;

public class Person extends GsonPropertyObject {

	public Person() {
		this.codeLogin = true;
		this.bindLogin = true;
		this.password = DEFAULT_PASSWORD;
		this.passwordPeriod = DEFAULT_PASSWORDPERIOD;
		this.register = REGISTER_TYPE_DISABLE;
		this.superPermission = true;
	}

	public static Person defaultInstance() {
		return new Person();
	}

	public static final String REGISTER_TYPE_DISABLE = "disable";
	public static final String REGISTER_TYPE_CAPTCHA = "captcha";
	public static final String REGISTER_TYPE_CODE = "code";

	public static final String ICON_MALE = "iVBORw0KGgoAAAANSUhEUgAAAEgAAABICAYAAABV7bNHAAAFmElEQVR42uVcT2gcVRhfxIMHERFFDyoq4t8WqgQpNQcVi6KCBUVEPRT0oBDFQw5VClsoxYOU2Ozsxpjimnnv+95uVBSkVOghBUElh/ZQsZQgooFWKBqkhxxyiN/3djeNuzOzMzvz5s2bPPggJJP585vv7+9931QqFld1cfFaD2Dck3J/XcrJmoBDLPwz/47/xsdUttuqA+yrS1R1wFWSjSGy2jkW9m0PYADPxgAlTM6WEqgZ0X7IkzibApg+gS8aiI+UApyG39pBD7WcHTgd8ST8XkMcc9ukfLWH/MePWYOzKRLOkCY95SQ4075/twf4tTFwNkHCE3WlHnQOIALnY+PgXJWmW9oj5ePkI/7MCyC61t/kj/a6oz0SpnPUng5IgMedAGcW4GZynut5A8Qyo9RdxY9cUr1pAxyWmsD3HXDOcNwWQHTtlgP+By/bAohM+0qz2byusOB8gnirNXB6Zjav7iuu/6GEzTZADdHaXWT/M24boLrA5wsLUE2IJ2wDxERbgUO8fNI+QOrF4lIbon2/bYCmAR4rLEDHhLiBQ61NgOgebi84rYoX7JkX/FXd2Lim6IniaYsAnXGh1BD2TEx96QJAr1usxd4pfjWv1B1MqFsA6N9PZXunI4QZzudfqOIJZxjFmoC3cgcI8QN3KNeFhes9wLVc/Y/v3+vWnpjEI/kBBJ85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/ak04Ej4hUupTHmhTsSRkym/IGVbyNmrw3F3TkZnF5m04j0s0qq8G8YT06z6harDnLpY2dnQX7Kji+vxA01ZwKKOPHlOHvJ2kR6goWvrDUuYGLbxWIjFPAvvsnIS5vn4rP70HwmD2fskoP4sYKeMGBRKJnvH8EP3/p9b8PicDEJqJztk/QdADoS9QaqskAAAAABJRU5ErkJggg\u003d\u003d";
	

	public static final String RegularExpression_Script = "^\\((.+?)\\)$";
	private static final String DEFAULT_PASSWORD = "(person.getMobile())";
	private static final Integer DEFAULT_PASSWORDPERIOD = 0;

	private Boolean codeLogin;
	private Boolean bindLogin;
	private String password;
	private Integer passwordPeriod;
	private String register;
	private Boolean superPermission;

	public String getPassword() {
		return StringUtils.isEmpty(this.password) ? DEFAULT_PASSWORD : this.password;
	}

	public Integer getPasswordPeriod() {
		return (null == this.passwordPeriod || this.passwordPeriod < 0) ? 0 : this.passwordPeriod;
	}

	public Boolean getSuperPermission() {
		return BooleanUtils.isTrue(this.superPermission) ? true : false;
	}

	public String getRegister() {
		if (StringUtils.equalsIgnoreCase(REGISTER_TYPE_CODE, this.register)) {
			return REGISTER_TYPE_CODE;
		} else if (StringUtils.equalsIgnoreCase(REGISTER_TYPE_CAPTCHA, this.register)) {
			return REGISTER_TYPE_CAPTCHA;
		} else {
			return REGISTER_TYPE_DISABLE;
		}
	}

	public Boolean getCodeLogin() {
		return BooleanUtils.isFalse(this.codeLogin) ? false : true;
	}

	public Boolean getBindLogin() {
		return BooleanUtils.isTrue(this.bindLogin) ? true : false;
	}

	public void setRegister(String register) {
		this.register = register;
	}

	public void setCodeLogin(Boolean codeLogin) {
		this.codeLogin = codeLogin;
	}

	public void setBindLogin(Boolean bindLogin) {
		this.bindLogin = bindLogin;
	}

	public void setSuperPermission(Boolean superPermission) {
		this.superPermission = superPermission;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public void setPasswordPeriod(Integer passwordPeriod) {
		this.passwordPeriod = passwordPeriod;
	}

}
